package com.example.gulimall.coupon.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.Objects;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.common.utils.PageUtils;
import com.example.common.utils.Query;

import com.example.gulimall.coupon.dao.SeckillSkuRelationDao;
import com.example.common.entity.coupon.SeckillSkuRelationEntity;
import com.example.gulimall.coupon.service.SeckillSkuRelationService;


@Service("seckillSkuRelationService")
public class SeckillSkuRelationServiceImpl extends ServiceImpl<SeckillSkuRelationDao, SeckillSkuRelationEntity> implements SeckillSkuRelationService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<SeckillSkuRelationEntity> page = this.page(
                new Query<SeckillSkuRelationEntity>().getPage(params),
                Wrappers.<SeckillSkuRelationEntity>lambdaQuery()
                    .eq(Objects.nonNull(params.get("promotionSessionId")),
                            SeckillSkuRelationEntity::getPromotionSessionId, params.get("promotionSessionId"))
        );

        return new PageUtils(page);
    }

}